﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using iShoppingBUS;
using iShoppingDTO;

namespace iShopping.Member.UserControl
{
    public partial class SanPham : System.Web.UI.UserControl
    {
        private List<SanPhamDTO> tb = new List<SanPhamDTO>();
        //List<TimeSpan> timeSpans = new List<TimeSpan>();
        //private double dtime = 86400;
        //double totalSeconds = 0;
        //int seconds = 0;
        //int minutes = 0;
        //private int hours = 0;
        //string time = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                tb = SanPhamBUS.getTopByDate(5);
                //ViewState["Time"] = dtime;
                DataList1.DataSource = tb;
                DataList1.DataBind();
            }
            //else
            //{
            //    dtime = (double)ViewState["Time"];
            //}
            for (int i = 0; i < DataList1.Items.Count; i++)
            {
                Label label = (Label)DataList1.Items[i].FindControl("Label1");
                label.Text = "00:00:00";
            }

        }
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            ImageButton imageButton = (ImageButton)sender;
            for (int i = 0; i < DataList1.Items.Count; i++)
            {
                ImageButton iButton = (ImageButton)DataList1.Items[i].FindControl("ImageButton1");
                if (imageButton.ClientID == iButton.ClientID)
                {
                    Response.Redirect("~/Member/DSSanPham.aspx?Value=" + iButton.AlternateText.Trim());
                }

            }
        }

     

        //protected void Timer1_Tick(object sender, EventArgs e)
        //{
        //    ViewState["Time"] = Convert.ToDouble(ViewState["Time"]) - 1;
        //    if (Convert.ToDouble(ViewState["Time"]) <= 0)
        //    {

        //    }
        //    else
        //    {
        //        totalSeconds = Convert.ToDouble(ViewState["Time"]);
        //        int temp = (int)totalSeconds / 60;
        //        seconds = (int)totalSeconds % 60;
        //        hours = temp / 60;
        //        minutes = temp % 60;

        //        time = hours + ":" + minutes + ":" + seconds;

        //        for (int i = 0; i < DataList1.Items.Count; i++)
        //        {
        //            Label label = (Label)DataList1.Items[i].FindControl("Label1");
        //            label.Text = time;

        //        }
        //    }
        //}
    }
}